home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / totem / plugins / bbc / bbc.py next >
Encoding:
Python Source  |  2009-04-14  |  3.2 KB  |  96 lines

  1. #!/usr/bin/python
  2. # coding=UTF-8
  3. #
  4. # Copyright (C) 2008 Tim-Philipp M√ºller <tim.muller@collabora.co.uk>
  5. # Copyright (C) 2008 Canonical Ltd.
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
  20. #
  21. # The Totem project hereby grant permission for non-gpl compatible GStreamer
  22. # plugins to be used and distributed together with GStreamer and Totem. This
  23. # permission are above and beyond the permissions granted by the GPL license
  24. # Totem is covered by.
  25. #
  26. # See license_change file for details.
  27.  
  28. import gobject
  29. gobject.threads_init()
  30. import pygst
  31. pygst.require ("0.10")
  32. import gst
  33.  
  34. import totem
  35. import gtk
  36. import gconf
  37. import time
  38. import os
  39. from contentview import ContentView
  40.  
  41. class BBCViewer(totem.Plugin):
  42.     def __init__ (self):
  43.         totem.Plugin.__init__ (self)
  44.         self.loaded_content = False
  45.  
  46.     def mapped (self, contentview):
  47.         gst.log('mapped')
  48.         if not self.loaded_content:
  49.           self.view.load()
  50.           self.loaded_content = True
  51.  
  52.     def activate (self, totem_object):
  53.         self.gconf_client = gconf.client_get_default ()
  54.         self.totem = totem_object
  55.                 self.view = ContentView()
  56.         self.view.connect('play-episode', self.playEpisode)
  57.         vbox = gtk.VBox()
  58.                 scrollwin = gtk.ScrolledWindow()
  59.                 scrollwin.add(self.view)
  60.                 scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
  61.                 scrollwin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
  62.                 vbox.pack_start(scrollwin, True, True)
  63.         vbox.show_all ()
  64.         totem_object.add_sidebar_page ("bbc", _("BBC"), vbox)
  65.         # connect to 'map' only after adding the sidebar page
  66.         self.view.connect('map', self.mapped)
  67.         gst.log('activated')
  68.  
  69.     def deactivate (self, totem_object):
  70.         totem_object.remove_sidebar_page ("bbc")
  71.         self.loaded_content = False
  72.  
  73.     def getConnectionSpeed(self):
  74.         speed_map = [ 14400, 19200, 28800, 33600, 34400,
  75.                       56000, 112000, 256000, 384000, 512000,
  76.                       1536000, 10752000 ]
  77.         speed_enum = self.gconf_client.get_int("/apps/totem/connection_speed")
  78.         if speed_enum >= 0 and speed_enum < len(speed_map):
  79.           speed_kbps = speed_map[speed_enum] / 1000
  80.         else:
  81.           speed_kbps = 0
  82.         gst.log('Configured connection speed #%d: %d kbit/s' % (speed_enum, speed_kbps))
  83.         return speed_kbps
  84.  
  85.     def playEpisode (self, view, episode):
  86.         gst.info('Playing episode ' + episode.title)
  87.         mrl = episode.getUri(self.getConnectionSpeed())
  88.         if mrl:
  89.           gst.log('Playing uri ' + mrl)
  90.           self.totem.action_set_mrl_and_play(mrl, None)
  91.           #self.totem.action_remote(totem.REMOTE_COMMAND_ENQUEUE, mrl)
  92.           #self.totem.action_remote(totem.REMOTE_COMMAND_PLAY, mrl)
  93.         else:
  94.           gst.error('No uri for episode ' + episode.title)
  95.  
  96.